

# delim ;  
clear all;
set matsize 11000 ;
eststo clear ;
capture program drop add_lab_FE;
capture log close ; 
log using "../logs/universe_maint.log", text replace;



*-------------------------****** OUTPUT SETTINGS *****---------------------;
*settings some settings that are common for the set of plots on this dofile; 
local pdf_plot_settings = 	`"scale(*1.5) ymtick(##4) leg(off) ylabel(0(0.01)0.03)"';

*settings for latex tables ;
local tex_settigns  = `" prehead(\begin{table}[H]\centering
	\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
	\caption{@title}
	\begin{tabular}{l*{@span}{c}}
	\hline\hline)
	postfoot(\hline\hline
	\multicolumn{@span}{m{1\textwidth}}{\begin{singlespace} \footnotesize Robust Standard Errors in Brackets. @starlegend.  @note  \end{singlespace} }
	\end{tabular}\end{table})	"'	;


*xlabel(1980(5)2010);
*ymtick(-0.2(0.2)0.6) ; 
*ylabel(-0.2(0.2)0.6);
*ysc(r(-0.2 0.6));
*xmtick(1984(1)2008) ; 
*----------------------------------------------------------------------------------;

****************************************;	
use "../data/state_year_all_80_15.dta", clear  ;


*---------------------------------------------------;
* - Generate variables and general cleanings ;
*---------------------------------------------------;
do "_programs_universe";
do "_setup_expenditure.do";
do "_cleaning_and_new_variables.do";

*real non k (maintenance exp from SF12a AND sf12 and per lane mile;
gen exp_M_IH_sf12_plm	= exp_IH_mtn_SF12_r/u_lane_miles_IH;
*real maint. from sf12 and per lane mile;
gen exp_M_IH_SF12a_plm	= exp_IH_mtn_SF12a_r/u_lane_miles_IH;


gen no_exp=cond(exp_L_IH_SF12a_r==. | exp_L_IH_SF12a_r==. | exp_L_IH_SF12a_r<=0,1,0);


drop if no_exp==1;

*------------------------------------------------;
* Run the regressions ;
*------------------------------------------------;
*All regressions;

tab year;


*figures showing year indicators;
reg exp_M_IH_SF12a_plm ibn.year,  noc robust;
plot_dummies;
copy "temp_t.pdf" "${output}/figures/FigureB3_maint.pdf", replace;
erase "temp_t.pdf";
copy "temp_betas.dta" "../intermediate_data/maintF12a_betas_1.dta", replace ;
erase "temp_betas.dta";

sum exp_IH_mtn_SF12a_r exp_M_IH_SF12a_plm;
sum exp_M_IH_sf12_plm exp_M_IH_SF12a_plm;

tab year;
log close;
exit;
